<?php
include 'cabecalhoAdm.php';
if (isset($_GET['comando']) == "excluir") {
    $metodo = "excluir";
} else {
    $metodo = "busca";
}

require_once '../../Controller/Controller.Publicidade.php';
?>
<div class="containers">
    <a href="admin_add_publicidade.php" >Adicionar publicidade</a>
    <form method="GET" action="<?php $_SERVER['PHP_SELF']; ?>">
        Buscar 
        <select name="tipo">
            <option value="b">Banner principal</option>
            <option value="l">Lateral</option>
        </select><input type="SUBMIT" value="Buscar" class="bt_buscar"/>
    </form>
    <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">
    <table summary="" >
        <tr><th>Id</th><th>Imagem</th><th>Tipo</th><th>Link</th><th>Status</th><th>Excluir</th><th>Editar</th></tr>
        <?php
        for ($i = 0; $i < count($listaPublicidades); $i++) {
            $pr = $listaPublicidades[$i];
            echo "<tr>";
            echo "<td>" . $pr->getId() . "</td>";
            echo "<td><img src='geraImagem.php?id=" . $pr->getId() . "' widht=40% height=40%/></td>";
            echo "<td>" . $pr->getTipo() . "</td>";
            echo "<td>" . $pr->getLink() . "</td>";
            echo "<td><input name='status[]' type='checkbox' value='". $pr->getId() . "' ";
            if($pr->getStatus() == 1){ echo "checked='checked'";  }
            echo "/></td>";
            echo '<td><a href="admin_publicidade.php?comando=excluir&id="' . $pr->getId() . '">X</a></td>';
            echo '<td><a href="admin_add_publicidade.php?comando=update&id=' . $pr->getId() . '">Editar</a></td>';
            echo "</tr>";
        }
        ?>        
    </table>
    <input type="SUBMIT" value="Salvar"/>
    </form>
</div>

</div>
</div>
</body>

</html>